/**
 * Created with IntelliJ IDEA
 * Description:
 * User: Administrator
 * Data: 2023 - 07 - 07
 * Time: 13:52
 */
/*
public class Solution3 extends VersionControl {
    public int firstBadVersion(int n) {
        int left = 1;
        int right = n;
        while(left <= right) {
            int mid = left + ((right - left) >> 1);
            if((isBadVersion(mid) == true) && (isBadVersion(mid - 1) == false)) {
                return mid;
            }else if(isBadVersion(mid) == true) {
                right = mid - 1;
            }else if(isBadVersion(mid) == false) {
                left = mid + 1;
            }
        }
        return -1;//这一行没用
    }
}

//以下二分查找方式的原理是什么？
public class Solution4 extends VersionControl {
    public int firstBadVersion(int n) {
        int left = 1, right = n;
        while (left < right) { // 循环直至区间左右端点相同
            int mid = left + (right - left) / 2;
            if (isBadVersion(mid)) {
                right = mid; // 答案在区间 [left, mid] 中
            } else {
                left = mid + 1; // 答案在区间 [mid+1, right] 中
            }
        }
        // 此时有 left == right，区间缩为一个点，即为答案
        return left;
    }
}
*/